package com.xiaoma.nio;


import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * 读数据
 */
public class NIOFileChannel03 {
    public static void main(String[] args) throws IOException {
        String  str = "hello xiaoma";
        FileInputStream stream = new FileInputStream("D:\\xiaoma.txt");
        FileChannel channel = stream.getChannel();
        ByteBuffer buffer = ByteBuffer.allocate(1024);
        channel.read(buffer);
        System.out.println(new String(buffer.array()));
        stream.close();
    }
}
